package sql;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class WhereSqlNode implements SqlNode {
    private String expression;
    private List<SqlNode> children = new ArrayList<>();

    public WhereSqlNode(String expr) {
        this.expression = expr;
    }

    public void addNode(SqlNode node) {
        children.add(node);
    }

    @Override
    public String build() {
        return this.expression + " WHERE " + children.stream().map(SqlNode::build).collect(Collectors.joining(" AND "));
    }
}
